package cn.gok.common.dao.backstage;

import cn.gok.common.entity.backstage.Article;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author: DxlinY
 * @apiNote: 商城头条资讯持久层
 * @date: 2020/9/27
 * @time: 10:53
 */
@Repository
public interface ArticleMapper extends BaseMapper <Article> {

    @Select("SELECT " +
            "ga.ARTICLE_ID, " +
            "ga.ARTICLE_TITLE, " +
            "ga.ARTICLE_TYPE, " +
            "ga.SOURCE, " +
            "ga.UPDATE_TIME, " +
            "ga.CLICK_COUNT, " +
            "ga.IS_ENABLED " +
            "FROM " +
            "g_article ga")
    List <Article> listAll(Object target);

    @Update("UPDATE " +
            "g_article " +
            "set " +
            "IS_ENABLED = #{isEnable} " +
            "where " +
            "ARTICLE_ID = #{articleId} ")
    int updateIsEnableById(long articleId, boolean isEnable);
}
